<!doctype html>

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">

    <link type="text/css" rel="stylesheet" href="GwtGaeFb.css">

    <title>GwtGaeFb - Facebook application - GWT, Google App Engine / Java, Facebook JS API</title>
    
    <script type="text/javascript" language="javascript">
    	window.dawidFBready = false;
    </script>
    
    <script type="text/javascript" language="javascript" src="gwtgaefb/gwtgaefb.nocache.js"></script>
  </head>

  <body>

<div id="fb-root"></div>
<script>


  window.fbAsyncInit = function() {
  	console.log("FB API loaded asynchronously");
  	
    FB.init({
      appId      : '237446839668202',
      channelUrl : '//gwtgaefb.appspot.com//channel.html',
      status     : true,
      cookie     : true,
      xfbml      : true,
      oauth      :true
    });

	console.log("FB API initialized");
    // Additional initialization code here
    
    //checking login status
    FB.getLoginStatus(function(response) {
	  if (response.status === 'connected') {
		//User logged and authorized
		window.dawidFBready = true;
	  } else if (response.status === 'not_authorized') {
	    //User logged in but app not authorized - redirecting to authorization screen
	    self.location.href = 'http://www.facebook.com/dialog/oauth/?client_id=237446839668202&redirect_uri=http://apps.facebook.com/gwtgaefb/&response_type=token';
	  } else {
	    //User not logged in to facebook
	    window.location.href = 'http://apps.facebook.com/gwtgaefb/';
	  }
	 });
  };

  // Load the SDK Asynchronously
  (function(d){
  	console.log("Loading SDK Asynchronously");
     var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
     js = d.createElement('script'); js.id = id; js.async = true;
     js.src = "//connect.facebook.net/en_US/all.js";
     d.getElementsByTagName('head')[0].appendChild(js);
   }(document));
</script>

    <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
    
    <noscript>
      <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
        Your web browser must have JavaScript enabled
        in order for this application to display correctly.
      </div>
    </noscript>

  </body>
</html>
